package com.haixiaoke.saas.callback;

import com.haixiaoke.saas.common.config.FaDaDaConfig;
import com.haixiaoke.saas.contract.service.impl.FaDaDaCallbackService;
import com.haixiaoke.saas.system.framework.manager.AsyncManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
import java.util.TimerTask;

/**
 * @Author panda
 * @Date 2024/5/27
 **/
@RestController
@RequestMapping("/callback/electronicVisa")
public class FaDaDaController {

    @Autowired
    private FaDaDaCallbackService faDaDaCallbackService;

    /**
     * 法大大电子签回调
     * <a href="https://dev.fadada.com/api-doc/DKO6NVNYH3/UMZTMGU1FSROCUQJ/5-1"/>
     */
    @ResponseBody
    @PostMapping("/fadada")
    public void fddEventCallback(@RequestBody Map<String, Object> map) {
        AsyncManager.me().execute(new TimerTask() {
            @Override
            public void run() {
                faDaDaCallbackService.disposeCallback(map);
            }
        });
    }
}
